﻿using AutoMapper;
using CarparkIMS_CMS.Infrastructure.Mapper;
using CarparkIMS_Model;
using Microsoft.AspNetCore.Mvc.Rendering;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace CarparkIMS_CMS.Models
{
    public class llqqCameraDoorMapping11TEST
    { 
        public int ID { get; set; }
        public string CameraIP { get; set; }
        public int DoorID { get; set; }
        //1 - In, 2 - Out
        public int TransactionTypeID { get; set; }
        public bool Deleted { get; set; }
        public virtual tbDoor Door { get; set; }

        public string ParkingPlaceId { get; set; }

        public string ParkingPlaceSharpNumber { get; set; }
    }

    public class CameraConfigModel   // : llqqCameraDoorMapping
    {
        public int ID { get; set; }
        [Required]
        public string CameraIP { get; set; }
        public int DoorID { get; set; }
        //1 - In, 2 - Out
        public int TransactionTypeID { get; set; }
        public bool Deleted { get; set; }
        public virtual tbDoor Door { get; set; }
        [Required]
        public string ParkingPlaceId { get; set; }
        [Required]
        public string ParkingPlaceSharpNumber { get; set; } 
        public int ParkingNoCalcType { get; set; }   //---------------
        public string DoorName { get; set; }
        public string TransactionType { get; set; }
        public List<SelectListItem> DoorList { get; set; }
        public List<SelectListItem> TransactionTypeList { get; } = EnumHelper.GetEnumList_int<TransactionTypeEnum>("");
    }
 
    public class CameraParkingModel 
    { 
        public int ID { get; set; }
        public string CameraIP { get; set; } 
        public bool Deleted { get; set; }
       
        public string ParkingPlaceId { get; set; } 
        public string ParkingPlaceSharpNumber { get; set; }

        public llqqNumberPlate llqqNumberPlate { get; set; }

    }

    public class CameraConfigModelAutoMapConfig : Profile, IOrderedMapperProfile
    {
        public CameraConfigModelAutoMapConfig()
        {
            CreateMap<CameraConfigModel, llqqCameraDoorMapping>()
                .ForMember(entity=>entity.Door, opt=>opt.Ignore());
            CreateMap<llqqCameraDoorMapping, CameraConfigModel>()
                .ForMember(entity=>entity.DoorName, opt=>opt.MapFrom(src=>src.Door.Name))
                .ForMember(entity => entity.TransactionType, opt => opt.MapFrom(src => EnumHelper.GetDescriptionFromEnumValue((TransactionTypeEnum)src.TransactionTypeID)));
        }

        #region Properties

        /// <summary>
        /// Order of this mapper implementation
        /// </summary>
        public int Order => 0;

        #endregion
    }
}
